<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
</script>
<body>
    <script>
        function find(n, m) {
            var arr =[];
            for (var i = 0; i < n; i++) {
                arr.push(i);
            }
            console.log(arr);

            while(arr.length > 1){
                for (var i = 0; i < m - 1; i++ ){
                    arr.push(arr.shift())
                    console.log(arr);
                }
                arr.shift();
            }
            return arr;
        }
        var re = find(20, 5);
        console.log(re);
    </script>
</body>
</html>